Micron Document
`:top
In `F33f`_`[computer science`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computer_science]`_`f, a `!preprocessor`! (or `!precompiler`!)`:cite-ref-1[`F5bf`_`[1`#cite-note-1]`_`f] is a `F33f`_`[program`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computer_program]`_`f that processes its input data to produce output that is used as input in another program. The output is said to be a `!preprocessed`! form of the input data, which is often used by some subsequent programs like `F33f`_`[compilers`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Compiler]`_`f. The amount and kind of processing done depends on the nature of the preprocessor; some preprocessors are only capable of performing relatively simple textual substitutions and `F33f`_`[macro`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Macro_(computer_science)]`_`f expansions, while others have the power of full-fledged `F33f`_`[programming languages`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Programming_language]`_`f.

A common example from `F33f`_`[computer programming`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computer_programming]`_`f is the processing performed on `F33f`_`[source code`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Source_code]`_`f before the next step of compilation. In some `F33f`_`[computer languages`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computer_language]`_`f (e.g., `F33f`_`[C`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=C_(programming_language)]`_`f and `F33f`_`[PL/I`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=PL/I_(programming_language)]`_`f) there is a phase of `F33f`_`[translation`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Compiler]`_`f known as `*preprocessing`*. It can also include macro processing, file inclusion and language extensions.

>>Contents

• `F0af`_`[Lexical preprocessors`#lexical-preprocessors]`_`f
• `F0af`_`[C preprocessor`#c-preprocessor]`_`f
• `F0af`_`[Other lexical preprocessors`#other-lexical-preprocessors]`_`f
• `F0af`_`[Syntactic preprocessors`#syntactic-preprocessors]`_`f
• `F0af`_`[Customizing syntax`#customizing-syntax]`_`f
• `F0af`_`[Extending a language`#extending-a-language]`_`f
• `F0af`_`[Specializing a language`#specializing-a-language]`_`f
• `F0af`_`[General purpose preprocessor`#general-purpose-preprocessor]`_`f
• `F0af`_`[See also`#see-also]`_`f
• `F0af`_`[References`#references]`_`f
• `F0af`_`[External links`#external-links]`_`f

-─

>>Lexical preprocessors

Lexical preprocessors are the lowest-level of preprocessors as they only require `F33f`_`[lexical analysis`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lexical_analysis]`_`f, that is, they operate on the source text, prior to any `F33f`_`[parsing`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Parser]`_`f, by performing simple substitution of `F33f`_`[tokenized`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lexical_analysis]`_`f character sequences for other tokenized character sequences, according to user-defined rules. They typically perform `F33f`_`[macro substitution`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Macro_substitution]`_`f, `F33f`_`[textual inclusion`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Header_file]`_`f of other files, and conditional compilation or inclusion.

>>>C preprocessor

The most common example of this is the `F33f`_`[C preprocessor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=C_preprocessor]`_`f, which takes lines beginning with '#' as `F33f`_`[directives`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Directive_(programming)]`_`f. The C preprocessor does not expect its input to use the syntax of the C language. Some languages take a different approach and use built-in language features to achieve similar things. For example:

• Instead of macros, some languages use aggressive inlining and templates.
• Instead of includes, some languages use compile-time imports that rely on type information in the object code.
• Some languages use `B100`F9d9if-then-else`f`b and `F33f`_`[dead code elimination`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Dead_code_elimination]`_`f to achieve `F33f`_`[conditional compilation`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Conditional_compilation]`_`f.

>>>Other lexical preprocessors

Other lexical preprocessors include the general-purpose `F33f`_`[m4`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=M4_(language)]`_`f, most commonly used in cross-platform build systems such as `F33f`_`[autoconf`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Autoconf]`_`f, and `F33f`_`[GEMA`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=General_purpose_macro_processor]`_`f, an open source macro processor which operates on patterns of context.

>>Syntactic preprocessors

Syntactic preprocessors were introduced with the `F33f`_`[Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lisp_programming_language]`_`f family of languages. Their role is to transform syntax trees according to a number of user-defined rules. For some programming languages, the rules are written in the same language as the program (compile-time reflection). This is the case with `F33f`_`[Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lisp_programming_language]`_`f and `F33f`_`[OCaml`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=OCaml]`_`f. Some other languages rely on a fully external language to define the transformations, such as the `F33f`_`[XSLT`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=XSLT]`_`f preprocessor for `F33f`_`[XML`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=XML]`_`f, or its statically typed counterpart CDuce.

Syntactic preprocessors are typically used to customize the syntax of a language, extend a language by adding new primitives, or embed a `F33f`_`[domain-specific programming language`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Domain-specific_programming_language]`_`f (DSL) inside a general purpose language.

>>>Customizing syntax

A good example of syntax customization is the existence of two different syntaxes in the `F33f`_`[Objective Caml`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=OCaml]`_`f programming language.`:cite-ref-2[`F5bf`_`[2`#cite-note-2]`_`f] Programs may be written indifferently using the "normal syntax" or the "revised syntax", and may be pretty-printed with either syntax on demand.

Similarly, a number of programs written in `F33f`_`[OCaml`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=OCaml]`_`f customize the syntax of the language by the addition of new operators.

>>>Extending a language

The best examples of language extension through macros are found in the `F33f`_`[Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lisp_programming_language]`_`f family of languages. While the languages, by themselves, are simple dynamically typed functional cores, the standard distributions of `F33f`_`[Scheme`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Scheme_(programming_language)]`_`f or `F33f`_`[Common Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Common_Lisp]`_`f permit imperative or object-oriented programming, as well as static typing. Almost all of these features are implemented by syntactic preprocessing, although it bears noting that the "macro expansion" phase of compilation is handled by the compiler in Lisp. This can still be considered a form of preprocessing, since it takes place before other phases of compilation.

>>>Specializing a language

One of the unusual features of the `F33f`_`[Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lisp_programming_language]`_`f family of languages is the possibility of using macros to create an internal DSL. Typically, in a large `F33f`_`[Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lisp_programming_language]`_`f-based project, a module may be written in a variety of such `F33f`_`[minilanguages`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Minilanguage]`_`f, one perhaps using a `F33f`_`[SQL`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=SQL]`_`f-based dialect of `F33f`_`[Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Lisp_programming_language]`_`f, another written in a dialect specialized for `F33f`_`[GUIs`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Graphical_user_interface]`_`f or pretty-printing, etc. `F33f`_`[Common Lisp`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Common_Lisp]`_`f's standard library contains an example of this level of syntactic abstraction in the form of the LOOP macro, which implements an Algol-like minilanguage to describe complex iteration, while still enabling the use of standard Lisp operators.

The `F33f`_`[MetaOCaml`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=MetaOCaml]`_`f preprocessor/language provides similar features for external DSLs. This preprocessor takes the description of the semantics of a language (i.e. an interpreter) and, by combining compile-time interpretation and code generation, turns that definition into a compiler to the `F33f`_`[OCaml`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=OCaml]`_`f programming language—and from that language, either to bytecode or to native code.

>>General purpose preprocessor

Most preprocessors are specific to a particular data processing task (e.g., `F33f`_`[compiling`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Compilers]`_`f the C language). A preprocessor may be promoted as being `*general purpose`*, meaning that it is not aimed at a specific usage or programming language, and is intended to be used for a wide variety of text processing tasks.

`F33f`_`[M4`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=M4_(computer_language)]`_`f is probably the most well known example of such a general purpose preprocessor, although the C preprocessor is sometimes used in a non-C specific role. Examples:

• using C preprocessor for `F33f`_`[JavaScript`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=JavaScript]`_`f preprocessing.`:cite-ref-3[`F5bf`_`[3`#cite-note-3]`_`f]`:cite-ref-4[`F5bf`_`[4`#cite-note-4]`_`f]
• using C preprocessor for `F33f`_`[devicetree`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Devicetree]`_`f processing within the `F33f`_`[Linux kernel`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Linux_kernel]`_`f.`:cite-ref-5[`F5bf`_`[5`#cite-note-5]`_`f]
• using `F33f`_`[M4`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=M4_(computer_language)]`_`f (see on-article example) or C preprocessor`:cite-ref-6[`F5bf`_`[6`#cite-note-6]`_`f] as a `F33f`_`[template engine`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Web_template_system]`_`f, to `F33f`_`[HTML`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=HTML]`_`f generation.
• `F33f`_`[imake`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Imake]`_`f, a `F33f`_`[make`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Make_(software)]`_`f interface using the C preprocessor, written for the `F33f`_`[X Window System`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=X_Window_System]`_`f but now deprecated in favour of `F33f`_`[automake`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Automake]`_`f.
• grompp, a preprocessor for simulation input files for `F33f`_`[GROMACS`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=GROMACS]`_`f (a fast, free, open-source code for some problems in `F33f`_`[computational chemistry`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computational_chemistry]`_`f) which calls the system C preprocessor (or other preprocessor as determined by the simulation input file) to parse the topology, using mostly the #define and #include mechanisms to determine the effective topology at grompp run time.

>>See also

• `F33f`_`[Directive (programming)`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Directive_(programming)]`_`f – Language construct that specifies how a compiler should process its input
• `F33f`_`[Metaprogramming`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Metaprogramming]`_`f – Programming paradigm
• `F33f`_`[Macros`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Macro_(computer_science)]`_`f – Rule for substituting a set input with a set output
• `F33f`_`[Source-to-source compiler`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Source-to-source_compiler]`_`f, also known as Transpiler – Translator of computer source code
• `F33f`_`[Sass (stylesheet language)`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Sass_(stylesheet_language)]`_`f – Stylesheet languagePages displaying short descriptions of redirect targets
• `F33f`_`[Stylus (stylesheet language)`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Stylus_(stylesheet_language)]`_`f – Stylesheet preprocessor languagePages displaying short descriptions of redirect targets
• `F33f`_`[Less (stylesheet language)`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Less_(stylesheet_language)]`_`f – Dynamic stylesheet languagePages displaying short descriptions of redirect targets
• `F33f`_`[Snippet (programming)`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Snippet_(programming)]`_`f – Small region of re-usable source code, machine code, or text
• `F33f`_`[Template engine`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Template_processor]`_`f – Software designed to combine templates with a data model to produce result documents
• The `F33f`_`[C preprocessor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=C_preprocessor]`_`f – Text processor used with C and C++ and other programming tools
• The `F33f`_`[OCaml preprocessor-pretty-printer`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Camlp4]`_`f – Programming software system
• The `F33f`_`[PL/I preprocessor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=PL/I_preprocessor]`_`f
• The `F33f`_`[Windows software trace preprocessor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Windows_software_trace_preprocessor]`_`f
• `F33f`_`[General-purpose macro processor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=General-purpose_macro_processor]`_`f – Macro processor that is not tied to or integrated with a particular language or piece of software.

>>References

`:cite-note-1`!1.`! `F0af`_`[↑`#cite-ref-1]`_`f "What is a precompiler?". `*`F33f`_`[IBM`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=IBM]`_`f`*.
`:cite-note-2`!2.`! `F0af`_`[↑`#cite-ref-2]`_`f The Revised syntax from The Caml language website
`:cite-note-3`!3.`! `F0af`_`[↑`#cite-ref-3]`_`f Show how to use `F33f`_`[C-preprocessor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=C_preprocessor]`_`f on JavaScript files. "JavaScript is Not Industrial Strength" `*by T. Snyder`*.
`:cite-note-4`!4.`! `F0af`_`[↑`#cite-ref-4]`_`f "The C Preprocessor in Javascript?". `*espresso-mode`*.
`:cite-note-5`!5.`! `F0af`_`[↑`#cite-ref-5]`_`f "Kernel/Git/Stable/Linux.git - Linux kernel stable tree".
`:cite-note-6`!6.`! `F0af`_`[↑`#cite-ref-6]`_`f Show how to use `F33f`_`[C-preprocessor`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=C_preprocessor]`_`f as `F33f`_`[template engine`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Template_processor]`_`f. "Using a C preprocessor as an HTML authoring tool" `*by J. Korpela`*, 2000.

>>External links

Look up

preprocessor

in Wiktionary, the free dictionary.

• DSL Design in Lisp
• Programming from the bottom up
• The Generic PreProcessor
• Gema, the General Purpose Macro Processor
• The PIKT piktc text, script, and configuration file preprocessor
• pyexpander, a python based general purpose macro processor
• minimac, a minimalist macro processor
• Java Comment Preprocessor

`c`F0af`_`[↑ Back to top`#top]`_`f`a